package mr.flow.weblog.bean;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * 自定义的聚合规则
 * 当key的ip相同的时候，就放入同一个reduce进行处理
 * @author 汤小萌
 *
 */
public class IpGroupingComparator extends WritableComparator {

	
	public IpGroupingComparator() {
		super(WeblogBean.class, true);
	}
	
	@Override
	public int compare(WritableComparable a, WritableComparable b) {
		WeblogBean aBean = (WeblogBean) a;
		WeblogBean bBean = (WeblogBean) b;
		return aBean.getRemote_addr().compareTo(bBean.getRemote_addr());
	}
	
}
